package com.test.daily.leetcode.y2022.m07.day0704.v04;

/**
 * @author Tom on 2022/7/4
 */
public class Solution {
    public int nearestRight(int[] arr, int target) {
        if (arr == null || arr.length < 1) {
            return -1;
        }
        int left = 0, right = arr.length - 1, mid = 0;
        int index = -1;
        while (left <= right) {
            mid = left + (right - left) / 2;
            if (arr[mid] < target) {
                index = mid;
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        return index;
    }
}
